
package ch.hearc.coursJava.GUI.j2D.watch;

import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;

import ch.hearc.coursJava.GUI.j2D.tools.JPanelDessin_A;

public class JPanelWatch extends JPanelDessin_A implements Runnable
	{

	/*------------------------------------------------------------------*\
	|*							Constructeurs							*|
	\*------------------------------------------------------------------*/

	public JPanelWatch()
		{
		this.line = new Line2D.Double(0, 0, 0, 100);
		this.cercle = new Ellipse2D.Double(-120, -120, 240, 240);
		alpha = 0;
		dAlpha = 0.0000001;
		}

	/*------------------------------------------------------------------*\
	|*							Methodes Public							*|
	\*------------------------------------------------------------------*/

	@Override
	public void run()
		{
		while(true)
			{
			incrementAlpha();
			this.repaint();
			}
		}

	public void incrementAlpha()
		{
		this.alpha += dAlpha;
		}

	/*------------------------------------------------------------------*\
	|*							Methodes Private						*|
	\*------------------------------------------------------------------*/

	@Override
	protected void dessiner(Graphics2D g2d)
		{
		g2d.translate(this.getWidth() / 2, this.getHeight() / 2);
		g2d.draw(cercle);
		g2d.rotate(alpha);
		g2d.draw(line);

		}

	/*------------------------------------------------------------------*\
	|*							Attributs Private						*|
	\*------------------------------------------------------------------*/

	// Tools
	private Ellipse2D cercle;
	private Line2D line;
	private double alpha;
	private double dAlpha;

	}
